<template>
  <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input
      v-model="taskname"
      @keydown.enter="hAdd"
      class="new-todo"
      placeholder="请输入任务名称"
      autofocus
    />
  </header>
</template>

<script>
export default {
  name: "TodoHeader",

  data() {
    return {
      taskname: "",
    };
  },
  methods: {
    hAdd(){
      if(this.taskname==='') return alert('没有数据')
      this.$emit('addTask',this.taskname)
      this.taskname = ''
    }
  },
};
</script>

<style lang="scss" scoped>
</style>